//
//  ColorProgressViewController.m
//  wuliangye
//
//  Created by yeeyuntech on 16/10/26.
//  Copyright © 2016年 jarze. All rights reserved.
//

#import "ColorProgressViewController.h"
#import "ColorProgressView.h"
#import "UIView+SetRect.h"
#import "GCD.h"
@interface ColorProgressViewController ()
@property (nonatomic, strong) GCDTimer           *timer;

@property (nonatomic, strong) ColorProgressView  *normalColorProgressView;
@property (nonatomic, strong) ColorProgressView  *redColorProgressView;
@end

@implementation ColorProgressViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor blackColor];
    {
        self.normalColorProgressView        = [[ColorProgressView alloc] initWithFrame:CGRectMake(0, 0, Width, 1)];
        self.normalColorProgressView.center = self.view.middlePoint;
        self.normalColorProgressView.y     -= 20;
        [self.normalColorProgressView startAnimation];
        [self.view addSubview:self.normalColorProgressView];
    }
    __weak typeof(self) weakSelf = self;
    self.timer                   = [[GCDTimer alloc] initInQueue:[GCDQueue mainQueue]];
    [self.timer event:^{
        
        [UIView animateWithDuration:0.5f delay:0 usingSpringWithDamping:2 initialSpringVelocity:0 options:0 animations:^{
            
            weakSelf.normalColorProgressView.progress = arc4random() % 101 / 100.f;
            
        } completion:nil];
        
    } timeIntervalWithSecs:1.f delaySecs:1.f];
    [self.timer start];

    // Do any additional setup after loading the view.
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
